import fasttext

def dm01_fasttest_load():
    mymodel = fasttext.train_unsupervised('./data/fil9')
    mymodel.save_model('./data/mymodel3.bin')
    mymodel2 = fasttext.load_model('./data/mymodel3.bin')
    print('加载')

def dm02_fasttext_get_word_vector():
    mymodel = fasttext.load_model('./data/mymodel3.bin')
    wordvec = mymodel.get_word_vector('the')
    print('wordvec--->',wordvec.shape,'\n',wordvec)
    wordvec = mymodel.get_word_vector('apple')
    print('wordvec--->',wordvec.shape,'\n',wordvec)

def dm03_get_nearest_neighbors():
    mymodel = fasttext.load_model('./data/mymodel3.bin')
    result = mymodel.get_nearest_neighbors('dog')
    print('result---->',result)

def md04_param():
    mymodel = fasttext.train_unsupervised('./data/fil9',epoch =1,model='cbow',lr=0.01,dim=300,thread=8)
    return



if __name__ == '__main__':
    print('ok')
    dm03_get_nearest_neighbors()